package org.copper.ui
{
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.text.TextFormatAlign;

	public class CTextField extends CSprite
	{
		public static const CENTER_TEXT_ALIGN:uint = 0;
		public static const RIGHT_TEXT_ALIGN:uint = 1;
		public static const LEFT_TEXT_ALIGN:uint = 2;
		
		
		private var m_textField:TextField;
		private var m_textFormat:TextFormat;
		
		private var m_align:uint;
		
		public function CTextField()
		{
			super();
			m_align = CENTER_TEXT_ALIGN;
			m_textFormat = new TextFormat();
			m_textField = new TextField();
			m_textField.x = m_textField.y = 0;
			m_textFormat.align = TextFormatAlign.CENTER;
			addChild(m_textField);
			m_textField.width = this.width;
			m_textField.height = this.height;
			textColor = 0xffffff;
			m_textField.wordWrap = true;
			textSize = 40;
			m_textField.defaultTextFormat = m_textFormat;
		}
		
		public function get italic():Boolean
		{
			return m_textFormat.italic;
		}
		
		public function set italic(value:Boolean):void
		{
			m_textFormat.italic = value;
			m_textField.defaultTextFormat = m_textFormat;
		}
		
		public function get bold():Boolean
		{
			return m_textFormat.bold;
		}
		
		public function set bold(value:Boolean):void
		{
			m_textFormat.bold = value;
			m_textField.defaultTextFormat = m_textFormat;
		}
		
		public function get fontName():String
		{
			return m_textFormat.font;
		}
		
		public function set fontName(value:String):void
		{
			m_textFormat.font = value;
			m_textField.defaultTextFormat = m_textFormat;
		}
		
		public function get align():uint
		{
			return m_align;
		}
		
		public function set align(value:uint):void
		{
			m_align = value;
			switch(value)
			{
				case CENTER_TEXT_ALIGN:
					m_textFormat.align = TextFormatAlign.CENTER;
					break;
				case RIGHT_TEXT_ALIGN:
					m_textFormat.align = TextFormatAlign.RIGHT;
					break;
				case LEFT_TEXT_ALIGN:
					m_textFormat.align = TextFormatAlign.LEFT;
					break;
			}
			m_textField.defaultTextFormat = m_textFormat;
		}
		
		public function set textSize(value:Number):void
		{
			m_textFormat.size = value;
			m_textField.defaultTextFormat = m_textFormat;
		}
		
		public function get textSize():Number
		{
			return Number(m_textFormat.size);
		}
		
		public function get textColor():uint
		{
			return m_textField.textColor;
		}
		
		public function set textColor(value:uint):void
		{
			m_textField.textColor = value;
		}
		
		public function get text():String
		{
			return m_textField.text;
		}
		
		public function set text(value:String):void
		{
			m_textField.text = value;
		}
		
		
		public function get border():Boolean
		{
			return m_textField.border;
		}
		
		public function set border(value:Boolean):void
		{
			m_textField.border = value;
		}
		
		override public function get filters():Array
		{
			return m_textField.filters;
		}
		
		override public function set filters(value:Array):void
		{
			m_textField.filters = value;
		}
		
		
		
		
		override public function get height():Number
		{
			return m_textField.height;
		}
		
		override public function get width():Number
		{
			return m_textField.width;
		}
		
		override public function set height(value:Number):void
		{
			m_textField.height = value;
		}
		
		override public function set width(value:Number):void
		{
			m_textField.width = value;
		}
	}
}